package com.example.blog.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

//加载自定义的拦截器
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    //根据类名类型注入该类  和 自动装配bean形式不一样
    @Resource
    private JwtRequestFilter jwtRequestFilter;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//         加载该拦截器，拦截所有的请求
        registry.addInterceptor(jwtRequestFilter).addPathPatterns("/**")
                .excludePathPatterns().addPathPatterns("/login","/logout");
    }




}
